/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bs.beans.fiscal;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author Bone
 */
@Entity
@Table(name = "DUPLICATAS")
public class Duplicatas implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(generator = "GEN_DUPLICATAS",strategy = GenerationType.SEQUENCE)
    @SequenceGenerator(allocationSize = 1,name = "GEN_DUPLICATAS",sequenceName = "SQ_DUPLICATAS")
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "VENCIMENTO")
    @Temporal(TemporalType.DATE)
    private Date vencimento;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @Column(name = "VALOR")
    private BigDecimal valor;
    @Column(name = "DUPLICATA")
    private String duplicata;
    @JoinColumn(name = "NOTA", referencedColumnName = "ID", updatable = false, insertable = false)
    @ManyToOne
    private NotaFiscal nota;

    public Duplicatas() {
    }

    public Duplicatas(Integer id) {
        this.id = id;
    }

   

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        Integer oldId = this.id;
        this.id = id;
        changeSupport.firePropertyChange("id", oldId, id);
    }

   

    public Date getVencimento() {
        return vencimento;
    }

    public void setVencimento(Date vencimento) {
        Date oldVencimento = this.vencimento;
        this.vencimento = vencimento;
        changeSupport.firePropertyChange("vencimento", oldVencimento, vencimento);
    }

    public BigDecimal getValor() {
        return valor;
    }

    public void setValor(BigDecimal valor) {
        BigDecimal oldValor = this.valor;
        this.valor = valor;
        changeSupport.firePropertyChange("valor", oldValor, valor);
    }

    public String getDuplicata() {
        return duplicata;
    }

    public void setDuplicata(String duplicata) {
        String oldDuplicata = this.duplicata;
        this.duplicata = duplicata;
        changeSupport.firePropertyChange("duplicata", oldDuplicata, duplicata);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Duplicatas)) {
            return false;
        }
        Duplicatas other = (Duplicatas) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Apagar.Duplicatas[ id=" + id + " ]";
    }

    public NotaFiscal getNota() {
        return nota;
    }

    public void setNota(NotaFiscal nota) {
        NotaFiscal oldNota = this.nota;
        this.nota = nota;
        changeSupport.firePropertyChange("nota", oldNota, nota);
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
